package com.us.usws.biz;

import net.iwsh.core.common.GlobalConfig;

import org.apache.commons.lang3.StringUtils;

public class ResourceStorageReplacer {

	public static String getUserDir(String userUid) {
		String ret = GlobalConfig.getString("Storage/Avatar");
		ret = StringUtils.replace(ret, "{userUid}", userUid);
		return ret;
	}

	public static String getUserTmpDir(String userUid) {
		String ret = GlobalConfig.getString("Storage/TmpDir");
		ret = StringUtils.replace(ret, "{userUid}", userUid);
		return ret;
	}

	/**
	 * get user avatar
	 * @param avatar
	 * @return
	 */
	public static String getUserAvatarPath(String userUid, String avatar) {
		String ret = getUserDir(userUid);
		ret += "/" + avatar;
		return ret;
	}

	public static String getChannelDir(String channelUid) {
		String ret = GlobalConfig.getString("Storage/Channel");
		ret = StringUtils.replace(ret, "{channelUid}", channelUid);
		return ret;
	}

	public static String getChannelPicPath(String channelUid, String picture) {
		String ret = getChannelDir(channelUid);
		ret += "/" + picture;
		return ret;
	}

	public static String getVideoFileDir(String videoFileUid) {
		String ret = GlobalConfig.getString("Storage/Video");
		ret = StringUtils.replace(ret, "{videoFileUid}", videoFileUid);
		return ret;
	}

	public static String getVideoFilePath(String videoFileUid, String ext) {
		String ret = getVideoFileDir(videoFileUid);
		ret += "/" + videoFileUid + "." + ext;
		return ret;
	}

	public static String getVideoFileSnapshotPath(String videoFileUid, String snapshot) {
		String ret = getVideoFileDir(videoFileUid);
		ret += "/" + snapshot;
		return ret;
	}

	public static String getThemeDir(String themeUid) {
		String ret = GlobalConfig.getString("Storage/Theme");
		ret = StringUtils.replace(ret, "{themeUid}", themeUid);
		return ret;
	}

}
